//
//  GraphDynamicViewController.m
//  iRMAP
//
//  Created by Nico and Shang Forever on 5/6/14.
//  Copyright (c) 2014 engueroryan. All rights reserved.
//

#import "GraphDynamicViewController.h"
#import "SGSLineGraphView.h"

#import "ParserClass.h"
#import "Devices.h"
#import "DevicesCurrentTemperature-PGS.h"
#import "DevicesCurrentTemperature-Platinum.h"
#import "DevicesCurrentTemperature-CO2Incubator.h"
#import "DevicesCurrentTemperature-EGS-G2.h"
#import "DevicesCurrentTemperature-OFA_IFA_IFC_INA.h"

@interface GraphDynamicViewController ()

@end

@implementation GraphDynamicViewController



- (void)viewDidLoad
{
    [super viewDidLoad];
    
  //  self.view.transform = CGAffineTransformMakeRotation( M_PI / 2 );
    
    self.lineGraphView.minValue = 0;
    self.lineGraphView.maxValue = 10;
    
    self.lineGraphView.interval = self.lineGraphView.maxValue / self.lineGraphView.numYIntervals;
    
    
    
    SGSLineGraphViewComponent *component = [[SGSLineGraphViewComponent alloc] init];
    
    
    
    NSMutableArray *arr = [NSMutableArray array];
    NSMutableArray *arrPoint = [NSMutableArray array];
    DevicesCurrentTemperature_Platinum *devicesPlatinum;
    
    for (int i = 0; i < [[[ParserClass sharedItems] sensorLogs] count] ; i++) {
        
    Devices *devices = [[ParserClass sharedItems] sensorLogs][i];
        DevicesCurrentTemperature_PGS *devicesGoldSilver = [[ParserClass sharedItems] sensorLogs][i];
        devicesPlatinum = [[ParserClass sharedItems] sensorLogs][i];
        DevicesCurrentTemperature_CO2Incubator *devicesIncubator = [[ParserClass sharedItems] sensorLogs][i];
        DevicesCurrentTemperature_EGS_G2 *devicesEGSG2 = [[ParserClass sharedItems] sensorLogs][i];
        DevicesCurrentTemperature_OFA_IFA_IFC_INA *devicesOFAIFAIFCINA ;
        
        
        
       // arr = [[NSMutableArray alloc] initWithObjects:[devicesPlatinum occuranceTime], nil];
        
       // arrPoint = [[NSMutableArray alloc]initWithObjects:[devicesPlatinum chamberSetPoint], nil];
        
        [arr addObject:[devicesPlatinum occuranceTime]];
        [arrPoint addObject:[devicesPlatinum chamberSetPoint]];
        
        

        
    }
    
  //  NSLog(@"arr  = %@", arr);
    
    NSLog(@"data count arr = %i", [arr count]);
    NSLog(@"data count arr = %i", [arrPoint count]);
    //@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"]
    [component setTitle:@"Test"];
    [component setPoints:@[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10"]];
    [component setShouldLabelValues:YES];
    [component setLabelFormat:@"%i"];
    [component setColour:[UIColor colorWithRed:0/255.0 green:30/255.0 blue:66/255.0 alpha:1.0]];
    
    [self.lineGraphView setComponents:[@[component] mutableCopy]];
    
    [self.lineGraphView setXLabels:[@[@"date1",@"date2",@"date3",@"date4",@"date5",@"date6",@"date7",@"date8",@"date9",@"date10",@"date1",@"date2",@"date3",@"date4",@"date5",@"date6",@"date7",@"date8",@"date9",@"date10",@"date1",@"date2",@"date3",@"date4",@"date5",@"date6",@"date7",@"date8",@"date9",@"date10",@"date1",@"date2",@"date3",@"date4",@"date5",@"date6",@"date7",@"date8",@"date9",@"date10"] mutableCopy]];
//@[@"date1",@"date2",@"date3",@"date4",@"date5",@"date6",@"date7",@"date8",@"date9",@"date10"]
    
    
    
    [self.lineGraphView setupGraphPaths];
    [self.lineGraphView startDrawingAnimation];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskLandscape;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    return UIInterfaceOrientationLandscapeRight;
}

-(BOOL)shouldAutorotate{

    return NO;
}
@end
